using System;
using System.Collections.Generic;
using System.Text;

namespace OracleInternal.I18N
{
	[Serializable]
	internal class TLBConvGB18030 : TLBConv12Byte
	{
		private const int GB18030_MAXLIMIT = 64000;

		private const long BMPSTART = 2167439664L;

		private const long BMPEND = 2217845817L;

		private const int GBBMPSTART = 1687218;

		private const int GBBMPEND = 1726637;

		private const int USURSTART = 65536;

		private const int USUREND = 1114111;

		private const int GBSURSTART = 1876218;

		private const int GBSUREND = 2924793;

		private static readonly char[][] gbMapping = new char[206][]
		{
			new char[4]
			{
				'\u0080',
				'£',
				'\0',
				'#'
			},
			new char[4]
			{
				'¥',
				'¦',
				'$',
				'%'
			},
			new char[4]
			{
				'©',
				'\u00af',
				'&',
				','
			},
			new char[4]
			{
				'²',
				'¶',
				'-',
				'1'
			},
			new char[4]
			{
				'\u00b8',
				'Ö',
				'2',
				'P'
			},
			new char[4]
			{
				'Ø',
				'ß',
				'Q',
				'X'
			},
			new char[4]
			{
				'â',
				'ç',
				'Y',
				'^'
			},
			new char[4]
			{
				'ë',
				'ë',
				'_',
				'_'
			},
			new char[4]
			{
				'î',
				'ñ',
				'`',
				'c'
			},
			new char[4]
			{
				'ô',
				'ö',
				'd',
				'f'
			},
			new char[4]
			{
				'ø',
				'ø',
				'g',
				'g'
			},
			new char[4]
			{
				'û',
				'û',
				'h',
				'h'
			},
			new char[4]
			{
				'ý',
				'Ā',
				'i',
				'l'
			},
			new char[4]
			{
				'Ă',
				'Ē',
				'm',
				'}'
			},
			new char[4]
			{
				'Ĕ',
				'Ě',
				'~',
				'\u0084'
			},
			new char[4]
			{
				'Ĝ',
				'Ī',
				'\u0085',
				'\u0093'
			},
			new char[4]
			{
				'Ĭ',
				'Ń',
				'\u0094',
				'«'
			},
			new char[4]
			{
				'Ņ',
				'Ň',
				'¬',
				'®'
			},
			new char[4]
			{
				'ŉ',
				'Ō',
				'\u00af',
				'²'
			},
			new char[4]
			{
				'Ŏ',
				'Ū',
				'³',
				'Ï'
			},
			new char[4]
			{
				'Ŭ',
				'Ǎ',
				'Ð',
				'ı'
			},
			new char[4]
			{
				'Ǐ',
				'Ǐ',
				'Ĳ',
				'Ĳ'
			},
			new char[4]
			{
				'Ǒ',
				'Ǒ',
				'ĳ',
				'ĳ'
			},
			new char[4]
			{
				'Ǔ',
				'Ǔ',
				'Ĵ',
				'Ĵ'
			},
			new char[4]
			{
				'Ǖ',
				'Ǖ',
				'ĵ',
				'ĵ'
			},
			new char[4]
			{
				'Ǘ',
				'Ǘ',
				'Ķ',
				'Ķ'
			},
			new char[4]
			{
				'Ǚ',
				'Ǚ',
				'ķ',
				'ķ'
			},
			new char[4]
			{
				'Ǜ',
				'Ǜ',
				'ĸ',
				'ĸ'
			},
			new char[4]
			{
				'ǝ',
				'Ǹ',
				'Ĺ',
				'Ŕ'
			},
			new char[4]
			{
				'Ǻ',
				'ɐ',
				'ŕ',
				'ƫ'
			},
			new char[4]
			{
				'ɒ',
				'ɠ',
				'Ƭ',
				'ƺ'
			},
			new char[4]
			{
				'ɢ',
				'ˆ',
				'ƻ',
				'ȟ'
			},
			new char[4]
			{
				'ˈ',
				'ˈ',
				'Ƞ',
				'Ƞ'
			},
			new char[4]
			{
				'ˌ',
				'\u02d8',
				'ȡ',
				'ȭ'
			},
			new char[4]
			{
				'\u02da',
				'ΐ',
				'Ȯ',
				'ˤ'
			},
			new char[4]
			{
				'\u03a2',
				'\u03a2',
				'\u02e5',
				'\u02e5'
			},
			new char[4]
			{
				'Ϊ',
				'ΰ',
				'\u02e6',
				'ˬ'
			},
			new char[4]
			{
				'ς',
				'ς',
				'\u02ed',
				'\u02ed'
			},
			new char[4]
			{
				'ϊ',
				'Ѐ',
				'ˮ',
				'\u0324'
			},
			new char[4]
			{
				'Ђ',
				'Џ',
				'\u0325',
				'\u0332'
			},
			new char[4]
			{
				'ѐ',
				'ѐ',
				'\u0333',
				'\u0333'
			},
			new char[4]
			{
				'ђ',
				'\u200f',
				'\u0334',
				'ự'
			},
			new char[4]
			{
				'‑',
				'‒',
				'Ỳ',
				'ỳ'
			},
			new char[4]
			{
				'‗',
				'‗',
				'Ỵ',
				'Ỵ'
			},
			new char[4]
			{
				'‚',
				'‛',
				'ỵ',
				'Ỷ'
			},
			new char[4]
			{
				'„',
				'․',
				'ỷ',
				'ỽ'
			},
			new char[4]
			{
				'‧',
				'\u202f',
				'Ỿ',
				'ἆ'
			},
			new char[4]
			{
				'‱',
				'‱',
				'ἇ',
				'ἇ'
			},
			new char[4]
			{
				'‴',
				'‴',
				'Ἀ',
				'Ἀ'
			},
			new char[4]
			{
				'‶',
				'›',
				'Ἁ',
				'Ἅ'
			},
			new char[4]
			{
				'‼',
				'₫',
				'Ἆ',
				'ώ'
			},
			new char[4]
			{
				'₭',
				'ℂ',
				'\u1f7e',
				'ΐ'
			},
			new char[4]
			{
				'℄',
				'℄',
				'\u1fd4',
				'\u1fd4'
			},
			new char[4]
			{
				'℆',
				'℈',
				'\u1fd5',
				'ῗ'
			},
			new char[4]
			{
				'ℊ',
				'ℕ',
				'Ῐ',
				'ΰ'
			},
			new char[4]
			{
				'℗',
				'℠',
				'ῤ',
				'\u1fed'
			},
			new char[4]
			{
				'™',
				'⅟',
				'\u1fee',
				'\u202b'
			},
			new char[4]
			{
				'Ⅼ',
				'Ⅿ',
				'\u202c',
				'\u202f'
			},
			new char[4]
			{
				'ⅺ',
				'\u218f',
				'‰',
				'⁅'
			},
			new char[4]
			{
				'↔',
				'↕',
				'⁆',
				'⁇'
			},
			new char[4]
			{
				'↚',
				'∇',
				'⁈',
				'₵'
			},
			new char[4]
			{
				'∉',
				'∎',
				'₶',
				'₻'
			},
			new char[4]
			{
				'∐',
				'∐',
				'₼',
				'₼'
			},
			new char[4]
			{
				'−',
				'∔',
				'₽',
				'\u20bf'
			},
			new char[4]
			{
				'∖',
				'∙',
				'\u20c0',
				'\u20c3'
			},
			new char[4]
			{
				'∛',
				'∜',
				'\u20c4',
				'\u20c5'
			},
			new char[4]
			{
				'∡',
				'∢',
				'\u20c6',
				'\u20c7'
			},
			new char[4]
			{
				'∤',
				'∤',
				'\u20c8',
				'\u20c8'
			},
			new char[4]
			{
				'∦',
				'∦',
				'\u20c9',
				'\u20c9'
			},
			new char[4]
			{
				'∬',
				'∭',
				'\u20ca',
				'\u20cb'
			},
			new char[4]
			{
				'∯',
				'∳',
				'\u20cc',
				'\u20d0'
			},
			new char[4]
			{
				'∸',
				'∼',
				'\u20d1',
				'\u20d5'
			},
			new char[4]
			{
				'∾',
				'≇',
				'\u20d6',
				'\u20df'
			},
			new char[4]
			{
				'≉',
				'≋',
				'\u20e0',
				'\u20e2'
			},
			new char[4]
			{
				'≍',
				'≑',
				'\u20e3',
				'\u20e7'
			},
			new char[4]
			{
				'≓',
				'≟',
				'\u20e8',
				'\u20f4'
			},
			new char[4]
			{
				'≢',
				'≣',
				'\u20f5',
				'\u20f6'
			},
			new char[4]
			{
				'≨',
				'≭',
				'\u20f7',
				'\u20fc'
			},
			new char[4]
			{
				'≰',
				'⊔',
				'\u20fd',
				'℡'
			},
			new char[4]
			{
				'⊖',
				'⊘',
				'™',
				'ℤ'
			},
			new char[4]
			{
				'⊚',
				'⊤',
				'℥',
				'ℯ'
			},
			new char[4]
			{
				'⊦',
				'⊾',
				'ℰ',
				'ⅈ'
			},
			new char[4]
			{
				'⋀',
				'⌑',
				'ⅉ',
				'↚'
			},
			new char[4]
			{
				'⌓',
				'\u245f',
				'↛',
				'⋧'
			},
			new char[4]
			{
				'⑪',
				'⑳',
				'⋨',
				'⋱'
			},
			new char[4]
			{
				'⒜',
				'⓿',
				'⋲',
				'⍕'
			},
			new char[4]
			{
				'╌',
				'╏',
				'⍖',
				'⍙'
			},
			new char[4]
			{
				'╴',
				'▀',
				'⍚',
				'⍦'
			},
			new char[4]
			{
				'▐',
				'▒',
				'⍧',
				'⍩'
			},
			new char[4]
			{
				'▖',
				'▟',
				'⍪',
				'⍳'
			},
			new char[4]
			{
				'▢',
				'▱',
				'⍴',
				'⎃'
			},
			new char[4]
			{
				'▴',
				'▻',
				'⎄',
				'⎋'
			},
			new char[4]
			{
				'▾',
				'◅',
				'⎌',
				'⎓'
			},
			new char[4]
			{
				'◈',
				'◊',
				'⎔',
				'⎖'
			},
			new char[4]
			{
				'◌',
				'◍',
				'⎗',
				'⎘'
			},
			new char[4]
			{
				'◐',
				'◡',
				'⎙',
				'⎪'
			},
			new char[4]
			{
				'◦',
				'☄',
				'⎫',
				'⏉'
			},
			new char[4]
			{
				'☇',
				'☈',
				'⏊',
				'⏋'
			},
			new char[4]
			{
				'☊',
				'☿',
				'⏌',
				'␁'
			},
			new char[4]
			{
				'♁',
				'♁',
				'␂',
				'␂'
			},
			new char[4]
			{
				'♃',
				'⺀',
				'␃',
				'ⱀ'
			},
			new char[4]
			{
				'⺂',
				'⺃',
				'ⱁ',
				'ⱂ'
			},
			new char[4]
			{
				'⺅',
				'⺇',
				'ⱃ',
				'ⱅ'
			},
			new char[4]
			{
				'⺉',
				'⺊',
				'ⱆ',
				'ⱇ'
			},
			new char[4]
			{
				'⺍',
				'⺖',
				'ⱈ',
				'ⱑ'
			},
			new char[4]
			{
				'⺘',
				'⺦',
				'ⱒ',
				'Ⱡ'
			},
			new char[4]
			{
				'⺨',
				'⺩',
				'ⱡ',
				'Ɫ'
			},
			new char[4]
			{
				'⺫',
				'⺭',
				'Ᵽ',
				'ⱥ'
			},
			new char[4]
			{
				'⺯',
				'⺲',
				'ⱦ',
				'Ⱪ'
			},
			new char[4]
			{
				'⺴',
				'⺵',
				'ⱪ',
				'Ⱬ'
			},
			new char[4]
			{
				'⺸',
				'⺺',
				'ⱬ',
				'Ɱ'
			},
			new char[4]
			{
				'⺼',
				'⻉',
				'Ɐ',
				'ⱼ'
			},
			new char[4]
			{
				'⻋',
				'\u2fef',
				'ⱽ',
				'ⶡ'
			},
			new char[4]
			{
				'\u2ffc',
				'\u2fff',
				'ⶢ',
				'ⶥ'
			},
			new char[4]
			{
				'〄',
				'〄',
				'ⶦ',
				'ⶦ'
			},
			new char[4]
			{
				'〘',
				'〜',
				'\u2da7',
				'ⶫ'
			},
			new char[4]
			{
				'〟',
				'〠',
				'ⶬ',
				'ⶭ'
			},
			new char[4]
			{
				'\u302a',
				'〽',
				'ⶮ',
				'ⷁ'
			},
			new char[4]
			{
				'〿',
				'\u3040',
				'ⷂ',
				'ⷃ'
			},
			new char[4]
			{
				'ゔ',
				'\u309a',
				'ⷄ',
				'ⷊ'
			},
			new char[4]
			{
				'ゟ',
				'゠',
				'ⷋ',
				'ⷌ'
			},
			new char[4]
			{
				'ヷ',
				'・',
				'ⷍ',
				'ⷑ'
			},
			new char[4]
			{
				'ヿ',
				'\u3104',
				'ⷒ',
				'\u2dd7'
			},
			new char[4]
			{
				'ㄪ',
				'\u321f',
				'ⷘ',
				'⻍'
			},
			new char[4]
			{
				'㈪',
				'㈰',
				'⻎',
				'⻔'
			},
			new char[4]
			{
				'㈲',
				'㊢',
				'⻕',
				'⽅'
			},
			new char[4]
			{
				'㊤',
				'㎍',
				'⽆',
				'\u302f'
			},
			new char[4]
			{
				'㎐',
				'㎛',
				'〰',
				'〻'
			},
			new char[4]
			{
				'㎟',
				'㎠',
				'〼',
				'〽'
			},
			new char[4]
			{
				'㎢',
				'㏃',
				'〾',
				'た'
			},
			new char[4]
			{
				'㏅',
				'㏍',
				'だ',
				'と'
			},
			new char[4]
			{
				'㏏',
				'㏐',
				'ど',
				'な'
			},
			new char[4]
			{
				'㏓',
				'㏔',
				'に',
				'ぬ'
			},
			new char[4]
			{
				'㏖',
				'㑆',
				'ね',
				'ポ'
			},
			new char[4]
			{
				'㑈',
				'㑲',
				'マ',
				'ㄈ'
			},
			new char[4]
			{
				'㑴',
				'㖝',
				'ㄉ',
				'㈲'
			},
			new char[4]
			{
				'㖟',
				'㘍',
				'㈳',
				'㊡'
			},
			new char[4]
			{
				'㘏',
				'㘙',
				'㊢',
				'㊬'
			},
			new char[4]
			{
				'㘛',
				'㤗',
				'㊭',
				'㖩'
			},
			new char[4]
			{
				'㤙',
				'㥭',
				'㖪',
				'㗾'
			},
			new char[4]
			{
				'㥯',
				'㧎',
				'㗿',
				'㙞'
			},
			new char[4]
			{
				'㧑',
				'㧞',
				'㙟',
				'㙬'
			},
			new char[4]
			{
				'㧠',
				'㩲',
				'㙭',
				'㛿'
			},
			new char[4]
			{
				'㩴',
				'㭍',
				'㜀',
				'㟙'
			},
			new char[4]
			{
				'㭏',
				'㱭',
				'㟚',
				'㣸'
			},
			new char[4]
			{
				'㱯',
				'㳟',
				'㣹',
				'㥩'
			},
			new char[4]
			{
				'㳡',
				'䁕',
				'㥪',
				'㳞'
			},
			new char[4]
			{
				'䁗',
				'䅞',
				'㳟',
				'㷦'
			},
			new char[4]
			{
				'䅠',
				'䌶',
				'㷧',
				'㾽'
			},
			new char[4]
			{
				'䌸',
				'䎫',
				'㾾',
				'䀱'
			},
			new char[4]
			{
				'䎭',
				'䎰',
				'䀲',
				'䀵'
			},
			new char[4]
			{
				'䎲',
				'䏜',
				'䀶',
				'䁠'
			},
			new char[4]
			{
				'䏞',
				'䓕',
				'䁡',
				'䅘'
			},
			new char[4]
			{
				'䓗',
				'䙋',
				'䅙',
				'䋍'
			},
			new char[4]
			{
				'䙍',
				'䙠',
				'䋎',
				'䋡'
			},
			new char[4]
			{
				'䙢',
				'䜢',
				'䋢',
				'䎢'
			},
			new char[4]
			{
				'䜤',
				'䜨',
				'䎣',
				'䎧'
			},
			new char[4]
			{
				'䜪',
				'䝻',
				'䎨',
				'䏹'
			},
			new char[4]
			{
				'䝽',
				'䞌',
				'䏺',
				'䐉'
			},
			new char[4]
			{
				'䞎',
				'䥆',
				'䐊',
				'䗂'
			},
			new char[4]
			{
				'䥈',
				'䥹',
				'䗃',
				'䗴'
			},
			new char[4]
			{
				'䥻',
				'䥼',
				'䗵',
				'䗶'
			},
			new char[4]
			{
				'䥾',
				'䦁',
				'䗷',
				'䗺'
			},
			new char[4]
			{
				'䦄',
				'䦄',
				'䗻',
				'䗻'
			},
			new char[4]
			{
				'䦇',
				'䦚',
				'䗼',
				'䘏'
			},
			new char[4]
			{
				'䦜',
				'䦞',
				'䘐',
				'䘒'
			},
			new char[4]
			{
				'䦠',
				'䦵',
				'䘓',
				'䘨'
			},
			new char[4]
			{
				'䦸',
				'䱶',
				'䘩',
				'䣧'
			},
			new char[4]
			{
				'䱸',
				'䲞',
				'䣨',
				'䤎'
			},
			new char[4]
			{
				'䲤',
				'䴒',
				'䤏',
				'䥽'
			},
			new char[4]
			{
				'䴚',
				'䶭',
				'䥾',
				'䨑'
			},
			new char[4]
			{
				'䶯',
				'䷿',
				'䨒',
				'䩢'
			},
			new char[4]
			{
				'龦',
				'\ud7ff',
				'䩣',
				'芼'
			},
			new char[4]
			{
				'\ue76c',
				'\ue76c',
				'芽',
				'芽'
			},
			new char[4]
			{
				'\ue7c8',
				'\ue7c8',
				'芾',
				'芾'
			},
			new char[4]
			{
				'\ue7e7',
				'\ue7f3',
				'芿',
				'苋'
			},
			new char[4]
			{
				'\ue815',
				'\ue815',
				'苌',
				'苌'
			},
			new char[4]
			{
				'\ue819',
				'\ue81d',
				'苍',
				'苑'
			},
			new char[4]
			{
				'\ue81f',
				'\ue825',
				'苒',
				'苘'
			},
			new char[4]
			{
				'\ue827',
				'\ue82a',
				'苙',
				'苜'
			},
			new char[4]
			{
				'\ue82d',
				'\ue830',
				'苝',
				'苠'
			},
			new char[4]
			{
				'\ue833',
				'\ue83a',
				'苡',
				'苨'
			},
			new char[4]
			{
				'\ue83c',
				'\ue842',
				'苩',
				'苯'
			},
			new char[4]
			{
				'\ue844',
				'\ue853',
				'苰',
				'苿'
			},
			new char[4]
			{
				'\ue856',
				'\ue863',
				'茀',
				'茍'
			},
			new char[4]
			{
				'\ue865',
				'狼',
				'茎',
				'鏔'
			},
			new char[4]
			{
				'來',
				'兩',
				'鏕',
				'鐠'
			},
			new char[4]
			{
				'梁',
				'璉',
				'鐡',
				'鐻'
			},
			new char[4]
			{
				'練',
				'罹',
				'鐼',
				'钌'
			},
			new char[4]
			{
				'裡',
				'藺',
				'钍',
				'钕'
			},
			new char[4]
			{
				'鱗',
				'廓',
				'钖',
				'钯'
			},
			new char[4]
			{
				'塚',
				'塚',
				'钰',
				'钰'
			},
			new char[4]
			{
				'晴',
				'晴',
				'钱',
				'钱'
			},
			new char[4]
			{
				'凞',
				'益',
				'钲',
				'钴'
			},
			new char[4]
			{
				'神',
				'羽',
				'钵',
				'钺'
			},
			new char[4]
			{
				'諸',
				'諸',
				'钻',
				'钻'
			},
			new char[4]
			{
				'逸',
				'都',
				'钼',
				'钽'
			},
			new char[4]
			{
				'飯',
				'\ufe2f',
				'钾',
				'飃'
			},
			new char[4]
			{
				'︲',
				'︲',
				'飄',
				'飄'
			},
			new char[4]
			{
				'﹅',
				'﹈',
				'飅',
				'飈'
			},
			new char[4]
			{
				'\ufe53',
				'\ufe53',
				'飉',
				'飉'
			},
			new char[4]
			{
				'﹘',
				'﹘',
				'飊',
				'飊'
			},
			new char[4]
			{
				'\ufe67',
				'\ufe67',
				'飋',
				'飋'
			},
			new char[4]
			{
				'\ufe6c',
				'\uff00',
				'飌',
				'饠'
			},
			new char[4]
			{
				'｟',
				'\uffdf',
				'饡',
				'駡'
			},
			new char[4]
			{
				'￦',
				'￮',
				'駢',
				'駪'
			}
		};

		public override int MinBytesPerChar => 1;

		public override int MaxBytesPerChar => 2;

		public TLBConvGB18030()
		{
			m_groupId = 9;
		}

		private int ToUnicodeGB(int srcChar, bool ccb)
		{
			if (BMPLinear(srcChar) >= 39419)
			{
				int ucs = 1752754 + BMPLinear(srcChar) - 1876218;
				return SurrogateUcs4ToUtf16(ucs);
			}
			if (srcChar >> 16 != 0)
			{
				int num = BMPOracle2Unicode(srcChar);
				if (num == 0)
				{
					if (!ccb)
					{
						throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
					}
					num = m_ucsCharReplacement;
				}
				return num;
			}
			int num2 = (srcChar >> 8) & 0xFF;
			int num3 = srcChar & 0xFF;
			if (m_ucsCharLevel1[num2] != '\uffff' && m_ucsCharLevel2[m_ucsCharLevel1[num2] + num3] != 65535)
			{
				return m_ucsCharLevel2[m_ucsCharLevel1[num2] + num3];
			}
			if (!ccb)
			{
				throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
			}
			return m_ucsCharReplacement;
		}

		private int ToOracleCharacterGB(char srcChar, char lowSurrogate, bool ccb)
		{
			if (lowSurrogate != 0)
			{
				int num = SurrogateUtf16ToUcs4(srcChar, lowSurrogate);
				if (num >= 65536 && num <= 1114111)
				{
					return BMPunLinear(1876218 + (num - 65536) - 1687218);
				}
				if (!ccb)
				{
					throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_BYTES"));
				}
				return m_2ByteOraCharReplacement[0];
			}
			int num2 = ((int)srcChar >> 8) & 0xFF;
			int num3 = srcChar & 0xFF;
			int num4;
			if (m_oraCharLevel1[num2] != 65535 && m_oraCharLevel2[m_oraCharLevel1[num2] + num3] != '\uffff')
			{
				num4 = m_oraCharLevel2[m_oraCharLevel1[num2] + num3] & 0xFFFF;
			}
			else
			{
				num4 = BMPUnicode2Oracle(srcChar);
				if (num4 == 0)
				{
					if (!ccb)
					{
						throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_BYTES"));
					}
					if (srcChar > '\u2fff')
					{
						return m_2ByteOraCharReplacement[0];
					}
					return m_1ByteOraCharReplacement;
				}
			}
			return num4;
		}

		private int GetCharsLengthGBImpl(byte[] bytes, int offset, int count, ref int bytesCounted)
		{
			int num = offset;
			int num2 = offset + count;
			if (num2 > bytes.Length)
			{
				num2 = bytes.Length;
			}
			int num3 = 0;
			while (num < num2)
			{
				int num4 = bytes[num] & 0xFF;
				if (num4 > MAX_7_8_BIT)
				{
					if (num + 1 >= num2)
					{
						bytesCounted = num - offset;
						break;
					}
					if ((bytes[num] & 0xFF) >= 129 && (bytes[num] & 0xFF) <= 254 && (bytes[num + 1] & 0xFF) >= 48 && (bytes[num + 1] & 0xFF) <= 57)
					{
						if (num + 3 >= num2)
						{
							bytesCounted = num - offset;
							break;
						}
						if ((bytes[num + 2] & 0xFF) >= 129 && (bytes[num + 2] & 0xFF) <= 254 && (bytes[num + 3] & 0xFF) >= 48 && (bytes[num + 3] & 0xFF) <= 57)
						{
							num4 = ((bytes[num] & 0xFF) << 24) | ((bytes[num + 1] & 0xFF) << 16) | ((bytes[num + 2] & 0xFF) << 8) | (bytes[num + 3] & 0xFF);
							num += 4;
							num3 = ((ToUnicodeGB(num4, ccb: true) >> 16 != 0) ? (num3 + 2) : (num3 + 1));
						}
						else
						{
							num3++;
						}
					}
					else
					{
						num3++;
						num += 2;
					}
				}
				else
				{
					num3++;
					num++;
				}
			}
			bytesCounted = num - offset;
			return num3;
		}

		public override int GetCharsLength(byte[] bytes, int byteOffset, int byteCount)
		{
			int bytesCounted = 0;
			return GetCharsLengthGBImpl(bytes, byteOffset, byteCount, ref bytesCounted);
		}

		private int GetBytesOffsetGBImpl(byte[] bytes, int offset, int count, ref int charCount)
		{
			int num = offset;
			int num2 = offset + count;
			if (num2 > bytes.Length)
			{
				num2 = bytes.Length;
			}
			int num3 = 0;
			while (num < num2 && num3 < charCount)
			{
				int num4 = bytes[num] & 0xFF;
				if (num4 > MAX_7_8_BIT)
				{
					if (num + 1 >= num2)
					{
						break;
					}
					if ((bytes[num] & 0xFF) >= 129 && (bytes[num] & 0xFF) <= 254 && (bytes[num + 1] & 0xFF) >= 48 && (bytes[num + 1] & 0xFF) <= 57)
					{
						if (num + 3 >= num2)
						{
							break;
						}
						if ((bytes[num + 2] & 0xFF) >= 129 && (bytes[num + 2] & 0xFF) <= 254 && (bytes[num + 3] & 0xFF) >= 48 && (bytes[num + 3] & 0xFF) <= 57)
						{
							num4 = ((bytes[num] & 0xFF) << 24) | ((bytes[num + 1] & 0xFF) << 16) | ((bytes[num + 2] & 0xFF) << 8) | (bytes[num + 3] & 0xFF);
							num += 4;
							num3 = ((ToUnicodeGB(num4, ccb: true) >> 16 != 0) ? (num3 + 2) : (num3 + 1));
						}
						else
						{
							num3++;
						}
					}
					else
					{
						num3++;
						num += 2;
					}
				}
				else
				{
					num3++;
					num++;
				}
			}
			charCount = num3;
			return num - offset;
		}

		public override int GetBytesOffset(byte[] bytes, int byteOffset, int byteCount, int charCount)
		{
			int charCount2 = charCount;
			return GetBytesOffsetGBImpl(bytes, byteOffset, byteCount, ref charCount2);
		}

		public override int GetCharsLength(ArraySegment<byte> bytes, int bytesOffset, int bytesCount)
		{
			int bytesCounted = 0;
			return GetCharsLengthGBImpl(bytes.Array, bytes.Offset + bytesOffset, bytesCount, ref bytesCounted);
		}

		public override int GetCharsLength(IList<ArraySegment<byte>> bytes, int bytesOffset, int bytesCount)
		{
			int num = 0;
			int bytesCounted = 0;
			int num2 = 0;
			int continuationOffset = 0;
			byte[] array = null;
			int num3 = 0;
			int idx = 0;
			int offSet = bytes[0].Offset;
			bool flag = false;
			if (bytesOffset > 0)
			{
				UTF16ConvUtility.GetSegementIndices(bytes, bytesOffset, ref idx, ref offSet);
			}
			for (int i = idx; i < bytes.Count; i++)
			{
				if (flag)
				{
					break;
				}
				int num4 = bytes[i].Offset + continuationOffset;
				int num5 = bytes[i].Count - continuationOffset;
				if (i == idx)
				{
					num4 = offSet + continuationOffset;
					num5 = bytes[i].Count - (offSet - bytes[i].Offset) - continuationOffset;
				}
				if (bytesCount - num2 <= num5)
				{
					num5 = bytesCount - num2;
					flag = true;
				}
				byte[] array2 = bytes[i].Array;
				int charsLengthGBImpl = GetCharsLengthGBImpl(array2, num4, num5, ref bytesCounted);
				num += charsLengthGBImpl;
				num2 += bytesCounted;
				if (bytesCounted < num5 && !flag && i < bytes.Count - 1)
				{
					if (array == null)
					{
						array = new byte[4];
					}
					byte[] array3 = bytes[i + 1].Array;
					int num6 = num4 + bytesCounted;
					byte b = array2[num6];
					byte b2 = 0;
					b2 = ((bytesCounted != num5 - 1) ? array2[num6 + 1] : array3[bytes[i + 1].Offset]);
					int buffer1Bytes = num5 - bytesCounted;
					if ((b & 0xFF) >= 129 && (b & 0xFF) <= 254 && (b2 & 0xFF) >= 48 && (b2 & 0xFF) <= 57)
					{
						UTF16ConvUtility.GetRemainingBytes(4, array2, num6, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num3 = 4;
					}
					else
					{
						UTF16ConvUtility.GetRemainingBytes(2, array2, num6, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num3 = 2;
					}
					charsLengthGBImpl = GetCharsLengthGBImpl(array, 0, num3, ref bytesCounted);
					num += charsLengthGBImpl;
					num2 += bytesCounted;
				}
				else
				{
					continuationOffset = 0;
				}
			}
			return num;
		}

		public override int ConvertBytesToChars(byte[] bytes, int offset, int count, char[] chars, int charOffset, ref int charCount, bool ccb)
		{
			int num = offset;
			if (num < 0)
			{
				num = 0;
			}
			int num2 = num + count;
			if (num2 > bytes.Length)
			{
				num2 = bytes.Length;
			}
			int num3 = charOffset;
			if (num3 < 0)
			{
				num3 = 0;
			}
			int num4 = num3 + charCount;
			if (num4 > chars.Length)
			{
				num4 = chars.Length;
			}
			while (num < num2 && num3 < num4)
			{
				int num5 = bytes[num] & 0xFF;
				if (num5 > MAX_7_8_BIT)
				{
					if (num + 1 >= num2)
					{
						if (ccb)
						{
							break;
						}
						throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
					}
					if ((bytes[num] & 0xFF) >= 129 && (bytes[num] & 0xFF) <= 254 && (bytes[num + 1] & 0xFF) >= 48 && (bytes[num + 1] & 0xFF) <= 57)
					{
						if (num + 3 >= num2)
						{
							break;
						}
						if ((bytes[num + 2] & 0xFF) >= 129 && (bytes[num + 2] & 0xFF) <= 254 && (bytes[num + 3] & 0xFF) >= 48 && (bytes[num + 3] & 0xFF) <= 57)
						{
							num5 = ((bytes[num] & 0xFF) << 24) | ((bytes[num + 1] & 0xFF) << 16) | ((bytes[num + 2] & 0xFF) << 8) | (bytes[num + 3] & 0xFF);
							num += 4;
							int num6 = ToUnicodeGB(num5, ccb);
							if (num6 >> 16 == 0)
							{
								chars[num3++] = (char)num6;
								continue;
							}
							if (num3 >= num4)
							{
								num -= 4;
								break;
							}
							chars[num3++] = (char)((uint)(num6 >> 16) & 0xFFFFu);
							chars[num3++] = (char)((uint)num6 & 0xFFFFu);
						}
						else
						{
							if (!ccb)
							{
								throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
							}
							chars[num3++] = (char)m_ucsCharReplacement;
						}
					}
					else
					{
						num5 = ((bytes[num] << 8) & 0xFF00) | (bytes[num + 1] & 0xFF);
						chars[num3++] = (char)ToUnicodeGB(num5, ccb);
						num += 2;
					}
				}
				else
				{
					chars[num3++] = (char)ToUnicodeGB(num5, ccb);
					num++;
				}
			}
			charCount = num3 - charOffset;
			return num - offset;
		}

		public override int ConvertBytesToUTF16(byte[] bytes, int offset, int count, byte[] utfbytes, int utfOffset, ref int utfCount, bool ccb)
		{
			int num = offset;
			if (num < 0)
			{
				num = 0;
			}
			int num2 = num + count;
			if (num2 > bytes.Length)
			{
				num2 = bytes.Length;
			}
			int num3 = utfOffset;
			if (num3 < 0)
			{
				num3 = 0;
			}
			int num4 = num3 + utfCount;
			if (num4 > utfbytes.Length)
			{
				num4 = utfbytes.Length;
			}
			while (num < num2 && num3 + 1 < num4)
			{
				int num5 = bytes[num] & 0xFF;
				if (num5 > MAX_7_8_BIT)
				{
					if (num + 1 >= num2)
					{
						if (ccb)
						{
							break;
						}
						throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
					}
					if ((bytes[num] & 0xFF) >= 129 && (bytes[num] & 0xFF) <= 254 && (bytes[num + 1] & 0xFF) >= 48 && (bytes[num + 1] & 0xFF) <= 57)
					{
						if (num + 3 >= num2)
						{
							break;
						}
						if ((bytes[num + 2] & 0xFF) >= 129 && (bytes[num + 2] & 0xFF) <= 254 && (bytes[num + 3] & 0xFF) >= 48 && (bytes[num + 3] & 0xFF) <= 57)
						{
							num5 = ((bytes[num] & 0xFF) << 24) | ((bytes[num + 1] & 0xFF) << 16) | ((bytes[num + 2] & 0xFF) << 8) | (bytes[num + 3] & 0xFF);
							num += 4;
							int num6 = ToUnicodeGB(num5, ccb);
							if (num6 >> 16 == 0)
							{
								utfbytes[num3++] = (byte)((ushort)num6 & 0xFFu);
								utfbytes[num3++] = (byte)((ushort)num6 >> 8);
								continue;
							}
							if (num3 + 3 >= num4)
							{
								num -= 4;
								break;
							}
							char[] array = new char[2]
							{
								(char)((uint)(num6 >> 16) & 0xFFFFu),
								(char)((uint)num6 & 0xFFFFu)
							};
							utfbytes[num3++] = (byte)(array[0] & 0xFFu);
							utfbytes[num3++] = (byte)((int)array[0] >> 8);
							utfbytes[num3++] = (byte)(array[1] & 0xFFu);
							utfbytes[num3++] = (byte)((int)array[1] >> 8);
						}
						else
						{
							if (!ccb)
							{
								throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_UNICODE"));
							}
							utfbytes[num3++] = (byte)((ushort)m_ucsCharReplacement & 0xFFu);
							utfbytes[num3++] = (byte)((ushort)m_ucsCharReplacement >> 8);
						}
					}
					else
					{
						num5 = ((bytes[num] << 8) & 0xFF00) | (bytes[num + 1] & 0xFF);
						char c = (char)ToUnicodeGB(num5, ccb);
						utfbytes[num3++] = (byte)(c & 0xFFu);
						utfbytes[num3++] = (byte)((int)c >> 8);
						num += 2;
					}
				}
				else
				{
					char c2 = (char)ToUnicodeGB(num5, ccb);
					utfbytes[num3++] = (byte)(c2 & 0xFFu);
					utfbytes[num3++] = (byte)((int)c2 >> 8);
					num++;
				}
			}
			utfCount = num3 - utfOffset;
			return num - offset;
		}

		protected override int ConvertByteArraySegListToCharsImpl<T>(IList<ArraySegment<byte>> bytes, int bytesOffset, int bytesCount, T[] chars, int charOffset, ref int charCount, bool bUseReplacementChar, ConvertByteToCharsDelegate<T> t)
		{
			int num = charOffset;
			int charCount2 = charCount;
			int num2 = 0;
			int num3 = 0;
			int continuationOffset = 0;
			byte[] array = null;
			int num4 = 0;
			int idx = 0;
			int offSet = bytes[0].Offset;
			bool flag = false;
			if (bytesOffset > 0)
			{
				UTF16ConvUtility.GetSegementIndices(bytes, bytesOffset, ref idx, ref offSet);
			}
			for (int i = idx; i < bytes.Count; i++)
			{
				if (flag)
				{
					break;
				}
				if (charCount2 <= 0)
				{
					break;
				}
				int num5 = bytes[i].Offset + continuationOffset;
				int num6 = bytes[i].Count - continuationOffset;
				if (i == idx)
				{
					num5 = offSet + continuationOffset;
					num6 = bytes[i].Count - (offSet - bytes[i].Offset) - continuationOffset;
				}
				if (bytesCount - num3 <= num6)
				{
					num6 = bytesCount - num3;
					flag = true;
				}
				int num7 = t(bytes[i].Array, num5, num6, chars, num, ref charCount2, bUseReplacementChar);
				num3 += num7;
				num += charCount2;
				num2 += charCount2;
				charCount2 = charCount - num2;
				if (charCount2 > 0 && num7 < num6 && !flag && i < bytes.Count - 1)
				{
					if (array == null)
					{
						array = new byte[4];
					}
					byte[] array2 = bytes[i + 1].Array;
					int num8 = num5 + num7;
					byte b = bytes[i].Array[num8];
					byte b2 = 0;
					b2 = ((num7 != num6 - 1) ? bytes[i].Array[num8 + 1] : array2[bytes[i + 1].Offset]);
					int buffer1Bytes = num6 - num7;
					if ((b & 0xFF) >= 129 && (b & 0xFF) <= 254 && (b2 & 0xFF) >= 48 && (b2 & 0xFF) <= 57)
					{
						UTF16ConvUtility.GetRemainingBytes(4, bytes[i].Array, num8, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num4 = 4;
					}
					else
					{
						UTF16ConvUtility.GetRemainingBytes(2, bytes[i].Array, num8, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num4 = 2;
					}
					num7 = t(array, 0, num4, chars, num, ref charCount2, bUseReplacementChar);
					if (num7 == 0)
					{
						break;
					}
					num3 += num7;
					num += charCount2;
					num2 += charCount2;
					charCount2 = charCount - num2;
				}
				else
				{
					continuationOffset = 0;
				}
			}
			charCount = num2;
			return num3;
		}

		public override int GetBytesOffset(IList<ArraySegment<byte>> bytes, int charCount)
		{
			int charCount2 = charCount;
			int num = 0;
			int num2 = 0;
			int continuationOffset = 0;
			byte[] array = null;
			int num3 = 0;
			for (int i = 0; i < bytes.Count; i++)
			{
				if (num >= charCount)
				{
					break;
				}
				int num4 = bytes[i].Offset + continuationOffset;
				int num5 = bytes[i].Count - continuationOffset;
				byte[] array2 = bytes[i].Array;
				int bytesOffsetGBImpl = GetBytesOffsetGBImpl(array2, num4, num5, ref charCount2);
				num2 += bytesOffsetGBImpl;
				num += charCount2;
				charCount2 = charCount - num;
				if (charCount2 > 0 && bytesOffsetGBImpl < num5 && i < bytes.Count - 1)
				{
					if (array == null)
					{
						array = new byte[4];
					}
					byte[] array3 = bytes[i + 1].Array;
					int num6 = num4 + bytesOffsetGBImpl;
					byte b = array2[num6];
					byte b2 = 0;
					b2 = ((bytesOffsetGBImpl != num5 - 1) ? array2[num6 + 1] : array3[bytes[i + 1].Offset]);
					int buffer1Bytes = num5 - bytesOffsetGBImpl;
					if ((b & 0xFF) >= 129 && (b & 0xFF) <= 254 && (b2 & 0xFF) >= 48 && (b2 & 0xFF) <= 57)
					{
						UTF16ConvUtility.GetRemainingBytes(4, bytes[i].Array, num6, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num3 = 4;
					}
					else
					{
						UTF16ConvUtility.GetRemainingBytes(2, bytes[i].Array, num6, buffer1Bytes, bytes, ref i, ref continuationOffset, array);
						num3 = 2;
					}
					bytesOffsetGBImpl = GetBytesOffsetGBImpl(array, 0, num3, ref charCount2);
					num2 += bytesOffsetGBImpl;
					num += charCount2;
					charCount2 = charCount - num;
				}
				else
				{
					continuationOffset = 0;
				}
			}
			return num2;
		}

		public override int GetBytesLength(char[] chars, int charOffset, int charCount)
		{
			int num = charOffset;
			int num2 = charOffset + charCount;
			int num3 = 65535;
			int num4 = 0;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > chars.Length)
			{
				num2 = chars.Length;
			}
			for (int i = num; i < num2; i++)
			{
				if (chars[i] >= '\ud800' && chars[i] < '\udc00')
				{
					if (i + 1 >= num2 || chars[i + 1] < '\udc00' || chars[i + 1] > '\udfff')
					{
						num4 += 2;
						continue;
					}
					num3 = ToOracleCharacterGB(chars[i], chars[i + 1], ccb: true);
					i++;
				}
				else
				{
					num3 = ToOracleCharacterGB(chars[i], '\0', ccb: true);
				}
				num4 = ((num3 >> 16 == 0) ? ((num3 >> 8 == 0) ? (num4 + 1) : (num4 + 2)) : (num4 + 4));
			}
			return num4;
		}

		public override int GetBytesLength(string chars, int charOffset, int charCount)
		{
			int num = charOffset;
			int num2 = charOffset + charCount;
			int num3 = 65535;
			int num4 = 0;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > chars.Length)
			{
				num2 = chars.Length;
			}
			for (int i = num; i < num2; i++)
			{
				if (chars[i] >= '\ud800' && chars[i] < '\udc00')
				{
					if (i + 1 >= num2 || chars[i + 1] < '\udc00' || chars[i + 1] > '\udfff')
					{
						num4 += 2;
						continue;
					}
					num3 = ToOracleCharacterGB(chars[i], chars[i + 1], ccb: true);
					i++;
				}
				else
				{
					num3 = ToOracleCharacterGB(chars[i], '\0', ccb: true);
				}
				num4 = ((num3 >> 16 == 0) ? ((num3 >> 8 == 0) ? (num4 + 1) : (num4 + 2)) : (num4 + 4));
			}
			return num4;
		}

		public override int GetBytesLength(byte[] utf16Bytes, int utf16BytesOffset, int utf16BytesCount)
		{
			int num = utf16BytesOffset;
			int num2 = utf16BytesOffset + utf16BytesCount;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > utf16Bytes.Length)
			{
				num2 = utf16Bytes.Length;
			}
			int num3 = 65535;
			int num4 = 0;
			for (int i = num; i < num2 - 1; i += 2)
			{
				int num5 = (utf16Bytes[i + 1] << 8) | utf16Bytes[i];
				if (num5 >= 55296 && num5 < 56320)
				{
					if (i + 3 >= num2)
					{
						num4 += 2;
						continue;
					}
					int num6 = (utf16Bytes[i + 3] << 8) | utf16Bytes[i + 2];
					if (num6 >= 56320 && num6 <= 57343)
					{
						num3 = ToOracleCharacterGB((char)num5, (char)num6, ccb: true);
						i++;
					}
				}
				else
				{
					num3 = ToOracleCharacterGB((char)num5, '\0', ccb: true);
				}
				num4 = ((num3 >> 16 == 0) ? ((num3 >> 8 == 0) ? (num4 + 1) : (num4 + 2)) : (num4 + 4));
			}
			return num4;
		}

		public override int ConvertCharsToBytes(char[] chars, int chars_offset, int chars_count, byte[] bytes, int bytes_begin, ref int bytes_count, bool ccb)
		{
			int num = chars_offset;
			int num2 = chars_offset + chars_count;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > chars.Length)
			{
				num2 = chars.Length;
			}
			if (bytes_begin < 0)
			{
				bytes_begin = 0;
			}
			int num3 = bytes_begin + bytes_count;
			if (num3 > bytes.Length)
			{
				num3 = bytes.Length;
			}
			int num4 = bytes_begin;
			int num5 = 0;
			int i;
			for (i = num; i < num2 && num4 < num3; i++)
			{
				bool flag = false;
				if (chars[i] >= '\ud800' && chars[i] < '\udbff')
				{
					if (i + 1 >= num2 || chars[i + 1] < '\udc00' || chars[i + 1] > '\udfff')
					{
						if (!ccb)
						{
							throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_BYTES"));
						}
						if (num4 + 1 >= num3)
						{
							break;
						}
						bytes[num4++] = (byte)((int)m_2ByteOraCharReplacement[0] >> 8);
						bytes[num4++] = (byte)m_2ByteOraCharReplacement[0];
						continue;
					}
					num5 = ToOracleCharacterGB(chars[i], chars[i + 1], ccb);
					flag = true;
					i++;
				}
				else
				{
					num5 = ToOracleCharacterGB(chars[i], '\0', ccb);
				}
				if (num5 >> 16 != 0)
				{
					if (num4 + 3 >= num3)
					{
						if (flag)
						{
							i--;
						}
						break;
					}
					bytes[num4++] = (byte)(num5 >> 24);
					bytes[num4++] = (byte)(num5 >> 16);
					bytes[num4++] = (byte)(num5 >> 8);
					bytes[num4++] = (byte)num5;
				}
				else if (num5 >> 8 != 0)
				{
					if (num4 + 1 >= num3)
					{
						if (flag)
						{
							i--;
						}
						break;
					}
					bytes[num4++] = (byte)(num5 >> 8);
					bytes[num4++] = (byte)num5;
				}
				else
				{
					bytes[num4++] = (byte)num5;
				}
			}
			bytes_count = num4 - bytes_begin;
			return i - num;
		}

		public override int ConvertStringToBytes(string chars, int chars_offset, int chars_count, byte[] bytes, int bytes_begin, ref int bytes_count, bool ccb)
		{
			int num = chars_offset;
			int num2 = chars_offset + chars_count;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > chars.Length)
			{
				num2 = chars.Length;
			}
			if (bytes_begin < 0)
			{
				bytes_begin = 0;
			}
			int num3 = bytes_begin + bytes_count;
			if (num3 > bytes.Length)
			{
				num3 = bytes.Length;
			}
			int num4 = bytes_begin;
			int num5 = 0;
			int i;
			for (i = num; i < num2 && num4 < num3; i++)
			{
				bool flag = false;
				if (chars[i] >= '\ud800' && chars[i] < '\udbff')
				{
					if (i + 1 >= num2 || chars[i + 1] < '\udc00' || chars[i + 1] > '\udfff')
					{
						if (!ccb)
						{
							throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_BYTES"));
						}
						if (num4 + 1 >= num3)
						{
							break;
						}
						bytes[num4++] = (byte)((int)m_2ByteOraCharReplacement[0] >> 8);
						bytes[num4++] = (byte)m_2ByteOraCharReplacement[0];
						continue;
					}
					num5 = ToOracleCharacterGB(chars[i], chars[i + 1], ccb);
					flag = true;
					i++;
				}
				else
				{
					num5 = ToOracleCharacterGB(chars[i], '\0', ccb);
				}
				if (num5 >> 16 != 0)
				{
					if (num4 + 3 >= num3)
					{
						if (flag)
						{
							i--;
						}
						break;
					}
					bytes[num4++] = (byte)(num5 >> 24);
					bytes[num4++] = (byte)(num5 >> 16);
					bytes[num4++] = (byte)(num5 >> 8);
					bytes[num4++] = (byte)num5;
				}
				else if (num5 >> 8 != 0)
				{
					if (num4 + 1 >= num3)
					{
						if (flag)
						{
							i--;
						}
						break;
					}
					bytes[num4++] = (byte)(num5 >> 8);
					bytes[num4++] = (byte)num5;
				}
				else
				{
					bytes[num4++] = (byte)num5;
				}
			}
			bytes_count = num4 - bytes_begin;
			return i - num;
		}

		public override int ConvertUTF16ToBytes(byte[] utf16Bytes, int utf16BytesOffset, int utf16BytesCount, byte[] bytes, int byteOffset, ref int byteCount, bool bUseReplacementChar = true)
		{
			int num = utf16BytesOffset;
			int num2 = utf16BytesOffset + utf16BytesCount;
			if (num < 0)
			{
				num = 0;
			}
			if (num2 > utf16Bytes.Length)
			{
				num2 = utf16Bytes.Length;
			}
			if (byteOffset < 0)
			{
				byteOffset = 0;
			}
			int num3 = byteOffset + byteCount;
			if (num3 > bytes.Length)
			{
				num3 = bytes.Length;
			}
			int num4 = 65535;
			int num5 = byteOffset;
			int i;
			for (i = num; i < num2 - 1 && num5 < num3; i += 2)
			{
				bool flag = false;
				int num6 = (utf16Bytes[i + 1] << 8) | utf16Bytes[i];
				if (num6 >= 55296 && num6 < 56319)
				{
					if (i + 3 >= num2)
					{
						if (!bUseReplacementChar)
						{
							throw new DecoderFallbackException(I18nStringResourceManager.GetErrorMesg("FAIL_CONV_TO_BYTES"));
						}
						if (num5 + 1 >= num3)
						{
							break;
						}
						bytes[num5++] = (byte)((int)m_2ByteOraCharReplacement[0] >> 8);
						bytes[num5++] = (byte)m_2ByteOraCharReplacement[0];
						continue;
					}
					int num7 = (utf16Bytes[i + 3] << 8) | utf16Bytes[i + 2];
					if (num7 >= 56320 && num7 <= 57343)
					{
						num4 = ToOracleCharacterGB((char)num6, (char)num7, bUseReplacementChar);
						flag = true;
						i += 2;
					}
				}
				else
				{
					num4 = ToOracleCharacterGB((char)num6, '\0', bUseReplacementChar);
				}
				if (num4 >> 16 != 0)
				{
					if (num5 + 3 >= num3)
					{
						if (flag)
						{
							i -= 2;
						}
						break;
					}
					bytes[num5++] = (byte)(num4 >> 24);
					bytes[num5++] = (byte)(num4 >> 16);
					bytes[num5++] = (byte)(num4 >> 8);
					bytes[num5++] = (byte)num4;
				}
				else if (num4 >> 8 != 0)
				{
					if (num5 + 1 >= num3)
					{
						if (flag)
						{
							i -= 2;
						}
						break;
					}
					bytes[num5++] = (byte)(num4 >> 8);
					bytes[num5++] = (byte)num4;
				}
				else
				{
					bytes[num5++] = (byte)num4;
				}
			}
			byteCount = num5 - byteOffset;
			return i - num;
		}

		private int SurrogateUtf16ToUcs4(char highSur, char lowSur)
		{
			return (((0x3FF & highSur) << 10) | (lowSur & 0x3FF)) + 65536;
		}

		private int SurrogateUcs4ToUtf16(int ucs4)
		{
			return (((ucs4 - 65536 >> 10) | 0xD800) << 16) | ((ucs4 & 0x3FF) | 0xDC00);
		}

		private int BMPUnicode2Oracle(char uCodepoint)
		{
			int num = SearchgbMapping(uCodepoint, u2o: true);
			if (num == 65535)
			{
				return 0;
			}
			return BMPunLinear(num);
		}

		private int BMPOracle2Unicode(int oCodepoint)
		{
			int num = SearchgbMapping((char)BMPLinear(oCodepoint), u2o: false);
			if (num == 65535)
			{
				return 0;
			}
			return num;
		}

		private int BMPLinear(int codepoint)
		{
			return ((((codepoint >> 24) & 0xFF) * 10 + ((codepoint >> 16) & 0xFF)) * 126 + ((codepoint >> 8) & 0xFF)) * 10 + (codepoint & 0xFF) - 1687218;
		}

		private int BMPunLinear(int lin)
		{
			int num = (48 + lin % 10) & 0xFF;
			lin /= 10;
			int num2 = num + (((129 + lin % 126) & 0xFF) << 8);
			lin /= 126;
			int num3 = num2 + (((48 + lin % 10) & 0xFF) << 16);
			lin /= 10;
			return num3 + (((129 + lin) & 0xFF) << 24);
		}

		private int SearchgbMapping(char codepoint, bool u2o)
		{
			int num;
			int num2;
			int num3;
			if (u2o)
			{
				num = 1;
				num2 = 0;
				num3 = 2;
			}
			else
			{
				num = 3;
				num2 = 2;
				num3 = 0;
			}
			int num4 = gbMapping.Length - 1;
			int num5 = 0;
			while (num4 >= num5)
			{
				int num6 = (num4 + num5) / 2;
				if (gbMapping[num6][num2] <= codepoint && codepoint <= gbMapping[num6][num])
				{
					return codepoint - gbMapping[num6][num2] + gbMapping[num6][num3];
				}
				if (codepoint < gbMapping[num6][num2])
				{
					num4 = num6 - 1;
				}
				else if (codepoint > gbMapping[num6][num])
				{
					num5 = num6 + 1;
				}
			}
			return 65535;
		}

		public override void BuildUnicodeToOracleMapping()
		{
			m_oraCharLevel1 = new int[256];
			char[] array = new char[64000];
			int num = 0;
			int[][] array2 = new int[64000][];
			int num2 = 0;
			for (int i = 0; i < 64000; i++)
			{
				array2[i] = new int[2];
			}
			for (int j = 0; j < 256; j++)
			{
				m_oraCharLevel1[j] = 65535;
			}
			for (int k = 0; k < 64000; k++)
			{
				array[k] = '\uffff';
			}
			for (int l = 0; l < 65535; l++)
			{
				int num3 = ToUnicodeGB(l, ccb: true);
				if (num3 != m_ucsCharReplacement)
				{
					array2[num2][0] = num3;
					array2[num2][1] = l;
					num2++;
				}
			}
			for (int m = 0; m < array2.Length; m++)
			{
				int num4 = (array2[m][0] >> 8) & 0xFF;
				int num5 = array2[m][0] & 0xFF;
				if (m_oraCharLevel1[num4] == 65535)
				{
					m_oraCharLevel1[num4] = num;
					num += 256;
				}
				if (array[m_oraCharLevel1[num4] + num5] == '\uffff')
				{
					array[m_oraCharLevel1[num4] + num5] = (char)((uint)array2[m][1] & 0xFFFFu);
				}
			}
			if (extraUnicodeToOracleMapping != null)
			{
				int num6 = extraUnicodeToOracleMapping.Length;
				for (int n = 0; n < num6; n++)
				{
					int num7 = extraUnicodeToOracleMapping[n][0];
					int num4 = (num7 >> 8) & 0xFF;
					int num5 = num7 & 0xFF;
					num4 = (array2[n][0] >> 8) & 0xFF;
					num5 = array2[n][0] & 0xFF;
					if (m_oraCharLevel1[num4] == 65535)
					{
						m_oraCharLevel1[num4] = num;
						num += 256;
					}
					if (array[m_oraCharLevel1[num4] + num5] == '\uffff')
					{
						array[m_oraCharLevel1[num4] + num5] = (char)((uint)array2[n][1] & 0xFFFFu);
					}
				}
			}
			m_oraCharLevel2 = new char[num];
			for (int num8 = 0; num8 < num; num8++)
			{
				m_oraCharLevel2[num8] = array[num8];
			}
		}

		public override void ExtractCodepoints(IList<int[]> vtable)
		{
			int num = 65535;
			for (int i = 0; i <= num; i++)
			{
				try
				{
					vtable.Add(new int[2]
					{
						i,
						(ushort)ToUnicodeGB(i, ccb: true)
					});
				}
				catch
				{
				}
			}
		}

		public override void ExtractExtraMappings(IList<int[]> vtable)
		{
			if (extraUnicodeToOracleMapping != null)
			{
				for (int i = 0; i < extraUnicodeToOracleMapping.Length; i++)
				{
					vtable.Add(new int[2]
					{
						extraUnicodeToOracleMapping[i][0],
						extraUnicodeToOracleMapping[i][1]
					});
				}
			}
		}
	}
}
